﻿using ProjectCloth.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ProjectCloth.FrmUI
{
    public partial class InStockFrm : Form
    {
        private ClothContext db = new ClothContext();
        public InStockFrm(int orderItemId)
        {
            InitializeComponent();
            db = new ClothContext();
            companyCbb.DataSource = db.Companies.ToList();
            companyCbb.ValueMember = "Id";
            companyCbb.DisplayMember = "Name";
            makerCbx.DataSource = db.Users.ToList();
            makerCbx.ValueMember = "Id";
            makerCbx.DisplayMember = "Name";

            outmoneycbb.DataSource = db.CashAccounts.ToList();
            outmoneycbb.DisplayMember = "TradeTypeName";
            outmoneycbb.ValueMember = "Id";
            outmoneycbb.SelectedValue = 0;

            var orderItem = db.SaleOrderItems.Where(o => o.Id == orderItemId).FirstOrDefault();
            orderNoTxt.Text = db.SaleOrders.Where(o => o.Id == orderItem.OrderId).FirstOrDefault().OrderNo;
            DataGridViewComboEditBoxColumn cbb = dataGridView1.Columns["InStockProductNo"] as DataGridViewComboEditBoxColumn;
            if (cbb != null)
            {
                cbb.DefaultCellStyle.NullValue = "";// lbType.Text;//显示默认值 根据自己的需求改
                cbb.DataPropertyName = "";
                cbb.ValueMember = "Id";
                cbb.DisplayMember = "InstockNo";
                cbb.DataSource = db.InStockProducts.ToList();
            }
        }

        private void saveBtn_Click(object sender, EventArgs e)
        {
            var p = outmoneycbb.SelectedValue;
            //未付
            if (p == null)
            {
                //var instock=new inst
            }
            else
            {

            }
        }

        private void saveAndpayBtn_Click(object sender, EventArgs e)
        {
            {
                var p = outmoneycbb.SelectedValue;
                //未付
                if (p == null)
                {
                    MessageBox.Show("请选择支付方式！");
                }
                else
                {

                }
            }
        }
    }
}
